<!DOCTYPE html>
<html lang="en">

	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0">
		<title>Document</title>

		<style type="text/css">
			html,
			body {
				width: 100vw;
				height: 100vh;
			}
		</style>
		<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
		
		<script src="@/hybrid/js/cdn.bootcdn.net_ajax_libs_jquery.form_4.3.0_jquery.form.js"></script>

	</head>
	<body>
		<!-- <form id="ecpay-form" method="POST" target="_self"
			action="https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5"> -->
		<form id="ecpay-form" enctype="application/x-www-form-urlencoded" method="POST" target="_self"
			action="https://payment.ecpay.com.tw/Cashier/AioCheckOut/V5">
			<input id="CheckMacValue" type="hidden" name="CheckMacValue">
			<input id="ChoosePayment" type="hidden" name="ChoosePayment">
			<input id="EncryptType" type="hidden" name="EncryptType">
			<input id="ItemName" type="hidden" name="ItemName">
			<input id="MerchantID" type="hidden" name="MerchantID">
			<input id="MerchantTradeDate" type="hidden" name="MerchantTradeDate">
			<input id="MerchantTradeNo" type="hidden" name="MerchantTradeNo">
			<input id="OrderResultURL" type="hidden" name="OrderResultURL">
			<input id="PaymentType" type="hidden" name="PaymentType">
			<input id="ReturnURL" type="hidden" name="ReturnURL">
			<input id="TotalAmount" type="hidden" name="TotalAmount">
			<input id="TradeDesc" type="hidden" name="TradeDesc">
			
			<!-- <input id="OrderResultURL" type="hidden" name="OrderResultURL"> -->
			<input id="ClientBackURL" type="hidden" name="ClientBackURL">
			<input id="ItemURL" type="hidden" name="ItemURL">
			<input id="Remark" type="hidden" name="Remark">
			<input id="NeedExtraPaidInfo" type="hidden" name="NeedExtraPaidInfo">
			<input id="IgnorePayment" type="hidden" name="IgnorePayment">
			<!-- <input id="ChooseSubPayment" type="hidden" name="ChooseSubPayment"> -->
			<!-- <input id="StoreID" type="hidden" name="StoreID"> -->
			<!-- <input id="Language" type="hidden" name="Language"> -->
		</form>
		
		<!-- <iframe src="https://payment.ecpay.com.tw/Cashier/AioCheckOut/V5" frameborder="0"></iframe> -->
		
		<script type="text/javascript">
			// let form = JSON.parse(decodeURIComponent(window.location.search.substr(1).split('=')[1])).date
			let form = JSON.parse(decodeURIComponent(window.location.search.substr(1).split('=')[1]))
			
			// console.log(form,'form',form.CheckMacValue)
			
			window.document.getElementById('CheckMacValue').value = form.CheckMacValue
			window.document.getElementById('ChoosePayment').value = form.ChoosePayment
			window.document.getElementById('EncryptType').value = form.EncryptType
			window.document.getElementById('ItemName').value = form.ItemName
			window.document.getElementById('MerchantID').value = form.MerchantID
			window.document.getElementById('MerchantTradeDate').value = form.MerchantTradeDate
			window.document.getElementById('MerchantTradeNo').value = form.MerchantTradeNo
			window.document.getElementById('OrderResultURL').value = form.OrderResultURL
			window.document.getElementById('PaymentType').value = form.PaymentType
			window.document.getElementById('ReturnURL').value = form.ReturnURL
			window.document.getElementById('TotalAmount').value = form.TotalAmount
			window.document.getElementById('TradeDesc').value = form.TradeDesc
			
			window.document.getElementById('ClientBackURL').value = form.ClientBackURL
			window.document.getElementById('ItemURL').value = form.ItemURL
			window.document.getElementById('Remark').value = form.Remark
			window.document.getElementById('NeedExtraPaidInfo').value = form.NeedExtraPaidInfo
			window.document.getElementById('IgnorePayment').value = form.IgnorePayment
			// window.document.getElementById('ChooseSubPayment').value = form.ChooseSubPayment
			// window.document.getElementById('StoreID').value = form.StoreID
			// window.document.getElementById('Language').value = form.Language
			// console.log(document.getElementById("ecpay-form").contenttype,'form')
			
			document.getElementById("ecpay-form").submit();
			
			// console.log($,'jquery')
			$(function(){
				$('#ecpay-form').ajaxForm(function(data){
					if(data.status === 'fail'){
						console.log(data)
					} else {
						window.location.reload()
					}
				})
			})
			
			
		</script>
	</body>

</html>